﻿<!DOCTYPE html>
<html>

<head>
	<meta charset=utf-8>
	<title>Execution</title>
	<link href="../base.css" rel="stylesheet" type="text/css" />
</head>

<body>
	<div class="main">
		<h1>Execution</h1>
		
		<h2>Overview</h2>
		<p>
We describe how to render effects.
		</p>

		<p>
A sample of DirectX9 (VisualC++2013)「RuntimeSample/DirectX9.sln」
		</p>
		
		<p>
A sample of DirectX11 (VisualC++2013)「RuntimeSample/DirectX11.sln」
		</p>

		<h2>Initialization</h2>
		<p>
Instances of effect manager class and render manager class are created and initalized.<br>
This procedure is required to execute after initializing DirectX or OpenGL.
		</p>

		<h3>In the case of DirectX9</h3>
<pre>
<code>
// Create the instance of render manager
::EffekseerRenderer::Renderer* renderer = ::EffekseerRendererDX9::Renderer::Create( LPDIRECT3DDEVICE9, Maximum number of sprites );
// Create the instance of sound manager
::EffekseerSound::Sound* sound = ::EffekseerSound::Sound::Create( IXAudio2*, Number of voices for monaural playback, Number of voices for stereo playback );
// Create the instance of effect manager
::Effekseer::Manager* manager = ::Effekseer::Manager::Create( Maximum number of sprites );
</code>
</pre>

		
		<h3>In the case of DirectX11</h3>
<pre>
<code>
// Create the instance of render manager
::EffekseerRenderer::Renderer* renderer = ::EffekseerRendererDX11::Renderer::Create( ID3D11Device*, ID3D11DeviceContext*, Maximum number of sprites );
// Create the instance of sound manager
::EffekseerSound::Sound* sound = ::EffekseerSound::Sound::Create( IXAudio2*, Number of voices for monaural playback, Number of voices for stereo playback );
// Create the instance of effect manager
::Effekseer::Manager* manager = ::Effekseer::Manager::Create( Maximum number of sprites );
</code>
</pre>

		<h3>In the case of OpenGL</h3>
<pre>
<code>
// Create the instance of render manager
::EffekseerRenderer::Renderer* renderer = ::EffekseerRendererGL::Renderer::Create( Maximum number of sprites );
// Create the instance of effect manager
::Effekseer::Manager* manager = ::Effekseer::Manager::Create( Maximum number of sprites );
</code>
</pre>

	<p>
	OpenSL is currently unsupported.
	</p>
    
		<h2>Settings</h2>
		<p>
Render method, loading method, coordinate system, etc are specified after initializing.
		</p>

<pre>
<code>
// Specify render method. You can extend these methods.
manager->SetSpriteRenderer( renderer->CreateSpriteRenderer() );
manager->SetRibbonRenderer( renderer->CreateRibbonRenderer() );
manager->SetRingRenderer( renderer->CreateRingRenderer() );
manager->SetTrackRenderer( renderer->CreateTrackRenderer() );
manager->SetModelRenderer( renderer->CreateModelRenderer() );

// Specify texture image loading method (Extended when loading from package etc.)
manager->SetTextureLoader( renderer->CreateTextureLoader() );

// Specify the instance for playing sounds
manager->SetSoundPlayer( sound->CreateSoundPlayer() );

// Specify sound loading method (Extended when loading from package etc.)
manager->SetSoundLoader( sound->CreateSoundLoader() );

// Specify coordinate system (RH-Right hand, LH-Left hand)
manager->SetCoordinateSystem( Effekseer::CoordinateSystem::RH );
</code>
</pre>

		<h2>Loading and playing effects</h2>
		<p>
Loads an effect from a file. 
If you want to load a file from a package etc., you need to extend the loading method by specifying the data loading method.
		</p>
		<p>
The character code of a path is UTF16.
wchar_t for Windows,
For other OS, change from UTF 8 to UTF 16 using "::Effekseer::ConvertUtf8ToUtf16"
For C ++ 11, char16_t can also be used.
		</p>
<pre>
<code>
// Load an effect
Effekseer::Effect* effect = Effekseer::Effect::Create( manager, source path );
// Play the effect
Effekseer::Handle handle = manager->Play( effect, initial position );
</code>
</pre>

		<h2>Updating</h2>
		<p>
While updating the parameter of the effect being played, update it.
		</p>
<pre>
<code>
// Update a projection matrix
renderer->SetProjectionMatrix( ::Effekseer::Matrix44 );
// Update a camera matrix
renderer->SetCameraMatrix( ::Effekseer::Matrix44 );
// Update listener settings for 3D sound
sound->SetListener( position, focus, upper direction );
// Move or rotate effects(Many paramerters can be specified through ::Effekseer::Manager)
manager->AddLocation( handle, ::Effekseer::Vector3D );
// Update all effects
manager->Update();
</code>
</pre>

		<h2>Rendering</h2>
		<p>
Effects are rendered.
In the case of DirectX9, you need to execute it between BeginScene and EndScene.
		</p>
<pre>
<code>
renderer->BeginRendering();
manager->Draw();
renderer->EndRendering();
</code>
</pre>

		<h2>Terminating</h2>
		<p>
We terminate Effekseer. You need to execute it before releasing DirectX or OpenGL.
		</p>
<pre>
<code>
// Dispose an effects. When the effect is playing, the effect is released automatically after playing.
ES_SAFE_RELEASE( effect );
// Dispose the instance of effect manager
manager->Destroy();
// Dispose the instance ofsound
sound->Destroy();
// Dispose the instance of render manager
renderer->Destory();
</code>
</pre>


	</div>
</body>

</html>